﻿using System;
using System.Collections.Generic;
using System.Web;
using System.IO;

namespace sdamarketing
{
    public class SendToLogFile
    {
        public static void SendRecordToFIle(string record)
        {
            if (Directory.Exists(@"C:\ErrorLogs").Equals(false))
            {
                Directory.CreateDirectory(@"C:\ErrorLogs");
            }
            else
            {
                string path = @"C:\ErrorLogs\" + DateTime.Now.ToShortDateString() + "Log.txt";
                FileStream file = new FileStream(@path, FileMode.OpenOrCreate, FileAccess.ReadWrite);

                StreamWriter fileStream = new StreamWriter(file);
                fileStream.BaseStream.Seek(0, SeekOrigin.End);
                fileStream.Write(record);
                fileStream.Flush();
                fileStream.Close();
            }
        }
    }
}
